<?php

if (defined('NO_DIRECT')) {
	if (isset($_GET['i'])) {
		$follow_id = intval($_GET['i']);
		$follow_user = db_result('SELECT user_id FROM users WHERE user_id = '.$follow_id);
		if ($follow_user === false) {
			// gagal. follow user yg ga nyata
			echo 'gagal. follow user yg ga nyata';
		} else {
			if ($session['user']['user_id'] == $follow_id) {
				// gagal. follow diri sendiri so sad
				echo 'gagal. follow diri sendiri so sad';
			} else {
				$follow = db_result('SELECT user_by FROM follow WHERE user_by = '.$session['user']['user_id'].' AND user_who = '.$follow_id);
				if ($follow === false) {
					db_insert('INSERT INTO follow (user_by,user_who) VALUES ('.$session['user']['user_id'].','.$follow_id.')');
					// berhasil oye oye
					echo 'berhasil oye oye';
				} else {
					// gagal. udah pernah follow orang ini
					echo 'gagal. udah pernah follow orang ini';
				}
			}
		}
	}
}
